package com.aaa.day1108.demo04;

/**
 * @author ${崔灿}
 * @date 2022/11/08 17:46
 **/

public class Test01 {
    public static void main(String[] args) throws Exception {
        T t = new T();
        t.start();

        Thread.sleep(2000);
        System.out.println("主线程设置t线程的参数来防止损失");
        t.setFalg(false);
    }
}
class T extends Thread{
    private volatile boolean falg = true;

    public void setFalg(boolean falg) {
        this.falg = falg;
    }

    @Override
    public void run() {
        System.out.println("进入run方法");
        while (falg) {

        }
    }
}